import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

/*
    字母阵列
 */
public class LetterArray {
    public static void main(String[] args) throws IOException {
        char[] word = { 'L', 'A', 'N', 'Q', 'I', 'A', 'O' };
        InputStream data = new FileInputStream("C:\\Users\\45236\\Desktop\\a.txt");
        InputReader in = new InputReader(data);
        Deque<Integer> ns = new ArrayDeque();
        Deque<Integer> ms = new ArrayDeque();
        char[][] map = new char[100][100];
        for (int i = 0; i < 100; i++)
            for (int j = 0; j < 100; j++) {
                map[i][j] = in.nextChar();
                if (map[i][j] == 'L') {
                    ns.push(i);
                    ms.push(j);
                }
            }
        int[] nadd = { 1, -1, 0, 0, 1, 1, -1, -1};
        int[] madd = { 0, 0, 1, -1, 1, -1, -1, 1};
        int cnt = 0;
        while (!ns.isEmpty()) {
            int n = ns.pop();
            int m = ms.pop();
            int i, j, k, z = 8;
            while (z-- > 0) {
                for (k = 0, i = n, j = m; k < 7 && i >= 0 && i < 100 && j >= 0 && j < 100; k++, i += nadd[z], j += madd[z])
                    if (map[i][j] != word[k]) break;
                if (k == 7) cnt++;
            }
        }
        System.out.print(cnt);
    }

    static class InputReader {

        InputStream in;
        int next, len;
        byte[] buff;

        InputReader(InputStream in) { this(in, 8192); }

        InputReader(InputStream in, int buffSize) {
            this.buff = new byte[buffSize];
            this.next = this.len = 0;
            this.in = in;
        }

        int getByte() {
            if (next >= len)
                try {
                    next = 0;
                    len = in.read(buff);
                    if (len == -1) return -1;
                } catch (IOException e) { }
            return buff[next++];
        }

        char nextChar() {
            int c = getByte();
            while (c <= 32 || c == 127) c = getByte();
            return (char)c;
        }
    }
}
